module.exports = function ($scope, $resource, $modalInstance, $modal, toaster, getDate, obj) {

    $scope.formData = {
        'title': obj.title,
        'start_time': {'label': obj.start_time, 'opened': false},
        'end_time': {'label': obj.end_time, 'opened': false}
    }

    $scope.ok = function(){
        var para = {
            'group_code': obj.group_code,
            'sale_code': obj.sale_code,
            'check_type': obj.check_type,
            'start_time': getDate($scope.formData.start_time.label),
            'end_time': getDate($scope.formData.end_time.label)
        }
        if(!para.start_time){
            toaster.warning({title: '', body: '请设置公示开始时间'});
            return
        }
        if(!para.end_time){
            toaster.warning({title: '', body: '请设置公示结束时间'});
            return
        }
        $resource('/api/as/goc/applycheck/setPublicTime', {}, {}).save(para, function(res){
            if (res.errcode === 0) {
                toaster.success({title: '', body: '成功'});
                $modalInstance.close(para);
            } else {
                toaster.error({title: '', body: '设置公示时间失败, 请重试'});
            }
        });
    }

        //打开日历空间,选择时间
	$scope.dateOpen = function ($event, item) {
		$event.preventDefault();
		$event.stopPropagation();
		item.opened = true;
	};

    $scope.close = function () {
        $modalInstance.dismiss('cancel');
    }


};